package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.ProLd9;
import com.huizu.project.service.IProLd9Service;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 公益活动Controller
 * 
 * @author zhangmx
 * @date 2024-05-10
 */
@RestController
@RequestMapping("/project/prold9")
public class ProLd9Controller extends BaseController
{
    @Autowired
    private IProLd9Service proLd9Service;

    /**
     * 查询公益活动列表
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProLd9 proLd9)
    {
        startPage();
        List<ProLd9> list = proLd9Service.selectProLd9List(proLd9);
        return getDataTable(list);
    }

    /**
     * 导出公益活动列表
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:export')")
    @Log(title = "公益活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProLd9 proLd9)
    {
        List<ProLd9> list = proLd9Service.selectProLd9List(proLd9);
        ExcelUtil<ProLd9> util = new ExcelUtil<ProLd9>(ProLd9.class);
        util.exportExcel(response, list, "公益活动数据");
    }

    /**
     * 获取公益活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(proLd9Service.selectProLd9ById(id));
    }

    /**
     * 新增公益活动
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:add')")
    @Log(title = "公益活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProLd9 proLd9)
    {
        return toAjax(proLd9Service.insertProLd9(proLd9));
    }

    /**
     * 修改公益活动
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:edit')")
    @Log(title = "公益活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProLd9 proLd9)
    {
        return toAjax(proLd9Service.updateProLd9(proLd9));
    }

    /**
     * 删除公益活动
     */
    @PreAuthorize("@ss.hasPermi('project:prold9:remove')")
    @Log(title = "公益活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(proLd9Service.deleteProLd9ByIds(ids));
    }
}
